package com.mapas_google;

import java.util.ArrayList;

import android.app.AlertDialog;
import android.content.Context;
import android.graphics.drawable.Drawable;

import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;

public class MyOverlay extends ItemizedOverlay{

	private ArrayList mapOverlays=new ArrayList();
	private Context context1;
	
	
	public MyOverlay(Drawable defaultMarker) {
		super(boundCenterBottom(defaultMarker)); 
	}
	
	public MyOverlay(Drawable defaultMarker, Context context) {
		this(defaultMarker);
		this.context1=context;
	}	
	

	@Override
	protected OverlayItem createItem(int i) {
		// TODO Auto-generated method stub
		return (OverlayItem) mapOverlays.get(i);
	}

	@Override
	public int size() { 
		return mapOverlays.size();
	}
	
	@Override
	protected boolean onTap(int index) {
		OverlayItem item=(OverlayItem) mapOverlays.get(index);
		AlertDialog.Builder dialogo=new AlertDialog.Builder(context1);
		dialogo.setTitle(item.getTitle());
		dialogo.setMessage(item.getSnippet());
		dialogo.show();
		return true;
	}
	
	
	public void addOverlay(OverlayItem overlay){
		mapOverlays.add(overlay);
		this.populate();
	}
}
